﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using LynxWiki.DomainModel;

namespace LynxWiki.ViewModels
{
    public class WikiDirectoryViewData
    {
        public string RootDirectory { get; set; }
        public string ParentPath { get; set; }
        public string DirectoryName { get; set; }

        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd HH:mm:ss}")]
        public DateTime CreatedOn { get; set; }
        public string Creator { get; set; }

        [Display(Name = "# WikiDirectories")]
        public int cntWikiDirs { get; set; }
        [Display(Name = "# Topics in Directory")]
        public int cntTopicNames { get; set; }

        public List<WikiDirectory> WikiDirs { get; set; }
        //public List<string> TopicNames { get; set; }
        public List<WikiTopicListingViewData> TopicListing { get; set; }

        public WikiDirectoryViewData()
        {
            TopicListing = new List<WikiTopicListingViewData>();
        }

        public WikiDirectoryViewData(WikiDirectory wd)
        {
            TopicListing = new List<WikiTopicListingViewData>();
            if (wd != null) {
                RootDirectory = wd.RootDirectory;
                ParentPath = wd.ParentPath;
                DirectoryName = wd.DirectoryName;
                CreatedOn = wd.CreatedOn;
                Creator = wd.Creator;
            }
            else {
                RootDirectory = WikiRoot.RootDirectory;
            }
        }
    }
}